// 替换 #{key}中的字符串 为 obj[key] 的值
function replaceStr(orgStr: string, obj: object){
    return orgStr.replace(/#\{(.+?)\}/g, (matching: string, key: string, index: number) => obj[key] || matching)
}

console.log(replaceStr('名称是 #{name}', {name: '张三'}))